import { State } from "framework/FSM/AState";
import { ActionArgHelper } from "../../../ActionManager/ActionArgHelper";
import { EntityHelper } from "utils/entity/EntityHelper";
import { PositionHelper } from "utils/position/PositionHelper";
 

/**
 防守任务
 */ 
export class DefendRamTask<T extends IStateArg<Creep>>  extends State<T>
{

    //
    public  getActions(arg:T):Action[]
    {
        
       
        const memory = arg.entity.getNodeMemory();
        if(!memory.taskid)
        {
            return [];
        }
        const task =arg.task as ITask<ITeamTaskData<"defend">>;
        if(!task)
        {
            // 查找不到任务
            return []
        }
        
        const creep = arg.entity;
        const tactic = creep.getTactic();
        
        if(tactic.type == 1)
        {
            const enemy = Game.getObjectById(tactic.enemy[0]) as AttackObject
            if(enemy)
            {
                return [ActionArgHelper.actionDefend(creep,enemy)];
            }
           
        }
        else   if(tactic.type == 2)
        {
            // const enemy = Game.getObjectById(tactic.enemy[0]) as AttackObject
            // if(enemy)
            // {
            //     return [ActionArgHelper.actionDefend(creep,enemy)];
            // }
        }
        return  []
    }
}
